//
//  AKCommon.h
//  CocoaBean
//
//  Created by sleeper on 3/29/10.
//  Copyright 2010 __MyCompany__. All rights reserved.
//

#define AK_RELEASE(Obj) { [Obj release]; Obj = nil; }
#define AK_RELEASE_VIEW(Obj) { [Obj removeFromSuperview]; [Obj release]; Obj = nil; }
#define AK_RELEASE_CF(CFObj) { if (CFObj != NULL) { CFRelease(CFObj); CFObj = NULL; } }
#define AK_FREE(Ptr) { if (Ptr != NULL) { free(Ptr); Ptr = NULL; } }

#define AK_PROPERTY_RETAIN_BEGIN(Property, Param) if (Property != Param) { [Property release], Property = nil; Property = [Param retain];
#define AK_PROPERTY_COPY_BEGIN(Property, Param) if (Property != Param) { [Property release], Property = nil; Property = [Param copy];
#define AK_PROPERTY_END }

extern NSString * const kAKAPIKey;
extern NSString * const kAKSecret;
extern NSString * const kAKAppName;
extern NSString * const kAKCallbackName;

extern NSString * const kAKUserIdKeychainKey;

@protocol AKViewControllerDelegate <NSObject>
@optional
- (void)performOK:(UIViewController*)viewController;
- (void)performCancel:(UIViewController*)viewController;
@end

UINavigationController *AKNavigationControllerWithRootViewController(UIViewController *viewController);

NSString *AKStringForArrayOfStrings(NSArray *strings, NSString *separator);

/** Creates a mutable array which does not retain references to the objects it contains. */
NSMutableArray * AKCreateNonRetainingArray();

/** Creates a mutable set which does not retain references to the objects it contains. */
NSMutableSet * AKCreateNonRetainingSet();

/** Creates a mutable dictionary which does not retain references to the values it contains. */
NSMutableDictionary * AKCreateNonRetainingDictionary();

NSString * AKCreateUUID();